<!DOCTYPE html>
<html class="iframe-h">
<head>
<meta charset="UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>网站后台管理</title>
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/layui/css/layui.css" />
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/admin.css" />
<style>
.col-lg-12,.col-lg-6{ padding:0px;}
</style>
</head>

<body>
<div class=" clearfix">
  <div class="column-content-detail">
    <div class="col-lg-12">
    <div class="col-lg-6">
    <form class="layui-form" action="">
    <input type="hidden" name="tid" value="{$_tinfo.id}">
      <div class="layui-form-item">
        <div class="layui-inline tool-btn">
          <a class="layui-btn layui-btn-small layui-btn-normal addBtn" href="{:url('add',['tid'=>input('tid',0)])}"><i class="layui-icon">&#xe654;</i></a>
          <button class="layui-btn layui-btn-small layui-btn-danger delBtn"  data-url="{:url('del',['mid'=>$_tinfo['mid']])}"><i class="layui-icon">&#xe640;</i></button>
          <button class="layui-btn layui-btn-small layui-btn-warm listOrderBtn" data-url="{:url('sort',['mid'=>$_tinfo['mid']])}"><i class="iconfont">&#xe656;</i></button>
        </div>
        <div class="layui-inline">
          <select name="typeid" lay-filter="typeid">
            <option value="0">批量移动</option>
            {volist name='_tree' id='vo'}
            <option value="{$vo.id}">{$vo.flag} {$vo.title}</option>
            {/volist}
          </select>
        </div>
      </div>
    </form>
    </div>
    
    <div class="col-lg-6" style="text-align:right;">
    <form class="layui-form" action="">
    <input type="hidden" name="tid" value="{$_tinfo.id}">
      <div class="layui-form-item">
        <div class="layui-inline">
          <input type="text" name="q" placeholder="请输入关键字" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-inline">
          <select name="display" lay-filter="display">
            <option value="">请选择一个状态</option>
            <option value="1">显示</option>
            <option value="0">隐藏</option>
          </select>
        </div>
        <button class="layui-btn layui-btn-normal" lay-submit="search">搜索</button>
      </div>
    </form>
    </div>
    </div>
    <div class="layui-form" id="table-list">
      <form class="sort_from">
      <table class="layui-table" lay-even lay-skin="nob">
        <colgroup>
        <col width="50">
        <col class="hidden-xs" width="50">
        <col class="hidden-xs" width="100">
        <col>
        <col width="150">
        <col class="hidden-xs" width="200">
        <col class="hidden-xs" width="200">
        <col width="80">
        <col width="150">
        </colgroup>
        <thead>
          <tr>
            <th><input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose"></th>
            <th class="hidden-xs">ID</th>
            <th class="hidden-xs">排序</th>
            <th>名称</th>
            <th>栏目</th>
            <th class="hidden-xs">创建时间</th>
            <th class="hidden-xs">修改时间</th>
            <th>状态</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          {volist name='_list' id='vo'}
          <tr>
            <td><input type="checkbox" name="id[]" lay-skin="primary" value="{$vo.id}"></td>
            <td class="hidden-xs">{$vo.id}</td>
            <td class="hidden-xs"><input type="hidden" name="ids[]" value="{$vo.id}"><input type="text" name="sort[]" autocomplete="off" class="layui-input" value="{$vo.sort}" data-id="{$vo.id}"></td>
            <td><a href="{:url('edit',['tid'=>$vo['tid'],'id'=>$vo['id']])}" class="title">{$vo.title}</a></td>
            <td><a href="{:url('index',['tid'=>$vo['tid']])}" class="title">{$vo.tid|get_column_field}</a></td>
            <td class="hidden-xs">{$vo.create_time|time_format}</td>
            <td class="hidden-xs">{$vo.update_time|time_format}</td>
            <td><button class="layui-btn layui-btn-mini {if condition="$vo['display'] eq 1"}layui-btn-normal{else/}layui-btn-warm{/if} table-list-status" data-status="{$vo.display}" data-id="{$vo.id}" data-mid="{$vo.mid}">{if condition="$vo['display'] eq 1"}显示{else/}隐藏{/if} </button></td>
            <td><div class="layui-inline">
                <a class="layui-btn layui-btn-mini layui-btn-normal" href="{:url('edit',['tid'=>$vo['tid'],'id'=>$vo['id']])}"><i class="layui-icon">编辑</i></a>
                <button class="layui-btn layui-btn-mini layui-btn-danger del-btn" data-id="{$vo.id}"><i class="layui-icon">删除</i></button>
              </div></td>
          </tr>
          {/volist}
        </tbody>
      </table>
      </form>
      <div class="page-wrap">
      {$_page}
      </div>
    </div>
  </div>
</div>
<script src="__STATIC__/js/jquery.min.js" type="text/javascript" charset="utf-8"></script> 
<script src="__STATIC__/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script> 
<script src="__STATIC__/js/common.js" type="text/javascript" charset="utf-8"></script> 
<script>
var SCOPE = {
	del: "{:url('del',['mid'=>$_tinfo['mid']])}",
	status: "{:url('status')}"
}
layui.config({
	base: '__STATIC__/admin/js/module/'
}).extend({
	dialog: 'dialog',
	load: 'load',
	common: 'common'
});
layui.use(['form', 'jquery', 'layer', 'dialog', 'element'], function() {
	var form = layui.form(),
		layer = layui.layer,
		$ = layui.jquery,
		element = layui.element(),
		dialog = layui.dialog;

	//获取当前iframe的name值
	var iframeObj = $(window.frameElement).attr('name');
	//全选
	form.on('checkbox(allChoose)', function(data) {
		var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
		child.each(function(index, item) {
			item.checked = data.elem.checked;
		});
		form.render('checkbox');
	});
	form.render();
	
	$('.addBtn').mouseenter(function() {
		dialog.tips('添加', '.addBtn');
	})

	//删除
	$('.del-btn').on('click', function() {
		var id = $(this).attr('data-id');
		//common.del(SCOPE.del, id);
		ajax_get(conv_url(SCOPE.del)+"id="+id,true);
		return false;
	})
	
	//批量删除
	$('.delBtn').click(function() {
		var url=$(this).attr('data-url');
		dialog.confirm({
			message:'您确定要删除这些数据吗？',
			success:function(){
				$.post(url,$('.sort_from').serialize(),function(data){
					if(data.code == 1){
						var timer = setInterval(function(){
							window.parent.frames['iframe176'].location.reload();
						},2000);
						layer.msg(data.msg);
					}else{
						layer.msg(data.msg);
					}
				});
			},
			cancel:function(){
				
			}
		})
		return false;

	}).mouseenter(function() {
		dialog.tips('批量删除', '.delBtn');
	})

	//排序
	$('.listOrderBtn').click(function() {
		var url=$(this).attr('data-url');
		dialog.confirm({
			message:'您确定要进行排序吗？',
			success:function(){
				$.post(url,$('.sort_from').serialize(),function(data){
					if(data.code == 1){
						layer.msg(data.msg);
					}else{
						layer.msg(data.msg);
					}
				});
			},
			cancel:function(){
				
			}
		})
		return false;

	}).mouseenter(function() {
		dialog.tips('排序', '.listOrderBtn');
	})
	
	
	//修改状态
	$('#table-list').on('click', '.table-list-status', function() {
		var That = $(this); 
		var status = That.attr('data-status');
		var id = That.attr('data-id');
		var mid = That.attr('data-mid');
		var url = conv_url("{:url('status')}")+"mid="+mid+"&id="+id;
		if(status == 0) {
			That.removeClass('layui-btn-warm').addClass('layui-btn-normal').html('显示').attr('data-status', 1);
			url += "&display="+1;
		} else if(status == 1) {
			That.removeClass('layui-btn-normal').addClass('layui-btn-warm').html('隐藏').attr('data-status', 0);
			url += "&display="+0;
		}
		get_data(url,false);
		return false;
	})
	
	
	form.on('select(typeid)', function(data) {
		//console.log(data.value);
		if(data.value > 0){
			if($('input[name="id[]"]').is(":checked")){
				var url = "{:url('move',['mid'=>$_tinfo['mid']])}?tid="+data.value;
				dialog.confirm({
					message:'您确定要移动内容吗？',
					success:function(){
						$.post(url,$('.sort_from').serialize(),function(data){
							if(data.code == 1){
								layer.msg(data.msg);
								setInterval(function(){
									window.location.reload();	
								},2000);
							}else{
								layer.msg(data.msg);
							}
						});
					},
					cancel:function(){
						
					}
				})
			}else{
				layer.msg('请选择要移动的内容！');		
			}
		}else{
			layer.msg('请选择栏目！');	
		}
		return false;
	});
});
</script>

</body>
</html>